<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css">
<script type="text/javascript" src="//code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript" src="//code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.1.0.js"></script>
<script type="text/javascript">
	function boardList(boardNo){
		location.href="allView_board.do?boardNo="+boardNo;
	}
		function boardUpdate(no,boardNo, page){
			if(confirm("수정하시겠습니까?")){
				location.href="updateGo_board.do?no="+no+"&boardNo="+boardNo+"&page="+page;
				return false;
			}	
		}
		function boardDelete(no, boardNo, page){
			if(confirm("삭제하시겠습니까?")){
				location.href="deleteBoard_board.do?no="+no+"&boardNo="+boardNo+"&page="+page;
				return false;
			}	
		}
		$(document).ready(function(){
			var replyNo=$(":hidden[id=replyNo]").val();
			var no=$(":hidden[name=no]").val();
			var boardNo=$(":hidden[name=boardNo]").val();
			var page=$(":hidden[name=page]").val();
			$("input[id^='deleteReply']").click(function(){
					location.href="deleteReply_board.do?replyNo="+$(this).parent().parent().children().find("[id^='replyNo']").val()+"&no="+no+"&boardNo="+boardNo+"&page="+page;
			});
			$(":submit[name=writeReply]").click(function(){
				if($("#content").val()==""){
					alert("댓글을입력하세요");
					return false;
				}
			});
			$("#recommend").click(function(){
				if(confirm("추천 하시겠습니까?")){
					$.ajax({
						type:"post",
						url:"recommend_board.do",
						dataType:"json",
						data:"no="+no,
						success:function(json){
							if(json=="1"){
								alert("추천하였습니다.");
								location.href="getContentNo_board.do?no="+no+"&boardNo="+boardNo;
							}else{
								alert("이미 추천혹은 비추천 하셨습니다.");
							}
						}
					});
				}
			});
			$("#unrecommend").click(function(){
				if(confirm("비추천 하시겠습니까?")){
					$.ajax({
						type:"post",
						url:"unrecommend_board.do",
						dataType:"json",
						data:"no="+no,
						success:function(json){
							if(json=="1"){
								alert("비추천하였습니다.");
								location.href="getContentNo_board.do?no="+no+"&boardNo="+boardNo;
							}else{
								alert("이미 추천 혹은 비추천 하셨습니다.");
							}
						}
					});
				}
			});
		});

</script>
<style type="text/css">
.viewinfoBtn {
	font-size:12px;
	font-family:Verdana;
	font-weight:bold;
	-moz-border-radius:2px;
	-webkit-border-radius:2px;
	border-radius:2px;
	border:1px solid #dcdcdc;
	padding:5px 10px;
	text-decoration:none;
	background:-webkit-gradient( linear, left top, left bottom, color-stop(5%, #d9d5d9), color-stop(100%, #bababa) );
	background:-moz-linear-gradient( center top, #d9d5d9 5%, #bababa 100% );
	background:-ms-linear-gradient( top, #d9d5d9 5%, #bababa 100% );
	filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#d9d5d9', endColorstr='#bababa');
	background-color:#d9d5d9;
	color:#4f4f4f;
	display:inline-block;
	text-shadow:0px 0px 0px #ffffff;
 	-webkit-box-shadow:inset 0px 0px 0px 0px #ffffff;
 	-moz-box-shadow:inset 0px 0px 0px 0px #ffffff;
 	box-shadow:inset 0px 0px 0px 0px #ffffff;
}.viewinfoBtn:hover {
	background:-webkit-gradient( linear, left top, left bottom, color-stop(5%, #bababa), color-stop(100%, #d9d5d9) );
	background:-moz-linear-gradient( center top, #bababa 5%, #d9d5d9 100% );
	background:-ms-linear-gradient( top, #bababa 5%, #d9d5d9 100% );
	filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#bababa', endColorstr='#d9d5d9');
	background-color:#bababa;
}.viewinfoBtn:active {
	position:relative;
	top:1px;
}
</style>

</head>
<body>
<table align="center" width="80%">
<thead>
	<tr>
		<th>${requestScope.blist.no }-${requestScope.blist.title}</th>
	</tr>
</thead>
<tbody>
	<tr>
		<td align="center">
			<font size="2">작성자:${requestScope.blist.memberVO.nick } |	조회수: ${requestScope.blist.viewCount } |${requestScope.blist.writeDate} <br>
			 <c:if test="${requestScope.blist.orgFileName!=null }">
				<c:choose>
					<c:when test="${requestScope.boardNo==20 && sessionScope.vo.floatingPoint>=10 }">
						<a href="fileDownload_board.do?newFileName=${requestScope.blist.newFileName}&orgFileName=${requestScope.blist.orgFileName}&no=${requestScope.blist.no }">
						${requestScope.blist.orgFileName }
						</a>
					</c:when>
					<c:when test="${requestScope.boardNo==20 && sessionScope.vo.floatingPoint<10 }">
						포인트가 부족하여 다운로드가 불가합니다.
					</c:when>
				</c:choose>
			</c:if>
			</font>
			<hr>
		</td>
	</tr>
	<tr>
		<td height="100px">
			<c:choose>
				<c:when test="${requestScope.boardNo==21 }">
					<a href="${initParam.root}/view_bigsize.do?newfilename=${requestScope.blist.newFileName}" onclick="window.open(this.href, '', ''); return false;"><img src = "${initParam.root }/img/upload/${requestScope.blist.newFileName}" align="middle" width="500px"></a><br>
					${requestScope.blist.content }
				</c:when>
				<c:otherwise>
					${requestScope.blist.content }
				</c:otherwise>
			</c:choose>
		</td>
	</tr>
	<tr>
		<td align="center">
			<input type="hidden" id="no" value="${requestScope.blist.no}">
			<input type="image"  width="20px" src="${initParam.root}/img/like.jpg" id="recommend" > ${requestScope.recommend } &nbsp;
			<input type="image" width="20px" src="${initParam.root}/img/unlike.jpg" id="unrecommend">${requestScope.unrecommend }
		</td>
	</tr>
	<c:if test="${requestScope.rlist.subboardList != null}">
		<tr>
			<td>
				<hr>
				<table align="center">
				<tbody>
					<c:forEach items="${requestScope.rlist.subboardList}" var="rlist">
					<tr>
						<td colspan="2">
							<table>
								<tr>
									<td width="300">${rlist.memberVO.id}</td><td>${rlist.writeDate}</td>
								</tr>
							</table>
						</td>
					</tr>
					<tr>
						<td width="400"><input type="hidden" id="replyNo" value="${rlist.no}">${rlist.content}</td>
						<c:if test="${sessionScope.vo.id==rlist.memberVO.id }">
						<td align="right"><input type="button"  id="deleteReply" value="삭제" class="viewinfoBtn"></td>
						</c:if>
					</tr>
					</c:forEach>
					<tr>
						<td>
							<center>
								<ul id="css_page">
								<c:set var="pb" value="${requestScope.rlist.pb}"></c:set>
								<c:if test="${pb.previousPageGroup}">
									<li><a href="getContentView_board.do?pageNo=${pb.startPageOfPageGroup-1 }&no=${requestScope.blist.no}&boardNo=${requestScope.boardNo}&page=${requestScope.page}">
									◀</a></li>
								</c:if>
								 <c:forEach var="i" begin="${pb.startPageOfPageGroup }"  end="${pb.endPageOfPageGroup }">
								 <c:choose>
								 	<c:when test="${pb.nowPage!=i }">
								 	<li><a href="getContentView_board.do?pageNo=${i }&no=${requestScope.blist.no}&boardNo=${requestScope.boardNo}&page=${requestScope.page}">${i }</a></li>
								 	</c:when>
								 	<c:otherwise>
								 		 <li>${i}</li>
								 	</c:otherwise>
								 </c:choose>
								 </c:forEach>
								 <c:if test="${pb.nextPageGroup }">
									  <li><a href="getContentView_board.do?pageNo=${pb.endPageOfPageGroup+1}&no=${requestScope.blist.no}&boardNo=${requestScope.boardNo}&page=${requestScope.page}">▶</a></li>
								</c:if>
								</ul>
							</center>
					</tr>
					</tbody>
				</table>
			</td>
		</tr>
	</c:if>
	<tr>
		<td>
			<hr>
			<form id="replyForm" action="writeReply_subBoard.do">
				<table align="center">
					<tr><td>닉네임:<input type="text" name="nick" value="${sessionScope.vo.nick }" size="8" readonly="readonly"></td></tr>
					<tr><td><textarea id="content" name="content" rows="5" cols="50" ></textarea>
					<input type="hidden" name="no" value="${requestScope.blist.no}">
					<input type="hidden" name="boardNo" value="${requestScope.boardNo}">
					<input type="hidden" name="page" value="${requestScope.page}">
					<input type="submit"  value="댓글입력" class="viewinfoBtn" name="writeReply">
					</td>
					</tr>
				</table>
			</form>
		</td>
	</tr>
	<tr>
		<td>
			<hr>
				<center>
				<input type="button" class="viewinfoBtn" value="목록" onclick="boardList(${requestScope.boardNo })">
				<c:if test="${sessionScope.vo.nick==requestScope.blist.memberVO.nick }">
				<input type="button" class="viewinfoBtn" value="수정" onclick="boardUpdate(${requestScope.blist.no },${requestScope.boardNo },${requestScope.page })">
				<input type="button" class="viewinfoBtn" value="삭제" onclick="boardDelete(${requestScope.blist.no },${requestScope.boardNo },${requestScope.page })">
				</c:if>
				<c:if test="${sessionScope.vo.grade=='Manager'||sessionScope.vo.grade=='SubManager' }">
				<input type="button" class="viewinfoBtn" value="삭제" onclick="boardDelete(${requestScope.blist.no },${requestScope.boardNo },${requestScope.page })">
				</c:if>
				</center>
		</td>
	</tr>
</tbody>
</table>
</body>
</html>